package main

import "go-leetcode/leetcode/utils"

func main() {

}

func isSymmetric(root *utils.TreeNode) bool {
	if root == nil {
		return false
	}
	return compareLeftRight(root.Left, root.Right)
}

func compareLeftRight(leftNode, rightNode *utils.TreeNode) bool {
	if leftNode == nil && rightNode == nil {
		return true
	}
	if leftNode == nil && rightNode != nil {
		return false
	}
	if leftNode != nil && rightNode == nil {
		return false
	}
	if leftNode.Val != rightNode.Val {
		return false
	}

	return compareLeftRight(leftNode.Left, rightNode.Right) && compareLeftRight(leftNode.Right, rightNode.Left)
}
